﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SelectTopic.aspx.cs" Inherits="Meeting.Web.Admin.SelectBase.SelectTopic" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../../Css/SmartWizard/smart_wizard.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../Scripts/jquery-1.8.2.min.js"></script>
    <!--ardialog-->
    <script type="text/javascript" src="../../Scripts/artDialog4.1.6/artDialog.js?skin=blue"></script>
    <script type="text/javascript" src="../../Scripts/artDialog4.1.6/plugins/iframeTools.js"></script>
    <link href="../../Css/main.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/themes/cupertino/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/themes/icon.css" />
    <script type="text/javascript" src="../../Scripts/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../Scripts/locale/easyui-lang-zh_CN.js"></script>
    <script src="../../Scripts/datagrid-detailview.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/common.js"></script>
    <script src="../../Scripts/Json2.js" type="text/javascript"></script>
    <script type="text/javascript">

        var CategoryId = request("CategoryId");
        $(function () {
            art.dialog.removeData('result');
            //未用审核通过的topic
            $("#topicPass").datagrid({//GetPassTopic
                url: '../MeetingPre/MeetingOperation.ashx?method=GetPassTopic&CategoryId=' + CategoryId,
                pagination: true,
                singleSelect: true,
                pageSize: 15,
                pageNumber: 1, //默认索引页 
                view: detailview,
                detailFormatter: function (index, row) {
                    return '<div style="padding:2px"><table id="ddv-' + index + '"></table></div>';
                },
                onExpandRow: function (index, row) {
                    $('#ddv-' + index).datagrid({
                        url: '../MeetingPre/MeetingOperation.ashx?method=GetTopicApprove&Id=' + row.Id,

                        singleSelect: true,
                        rownumbers: true,
                        loadMsg: '',
                        height: 'auto',
                        columns: [[
                            { field: 'EmployeeName', title: '征求对象', width: 130 },
                              { field: 'IsPass', title: '审批状态', formatter: formatPass, hidden: true },
                              { field: 'InputType', title: '', hidden: true },
                              { field: 'Path', title: '', hidden: true },
                              { field: 'TopicId', title: '', hidden: true },
                              { field: 'EmployeeId', title: '', hidden: true },
                            { field: 'Comment', title: '签署意见', width: 220, formatter: formatComment }
                        ]],
                        onResize: function () {
                            $('#topicPass').datagrid('fixDetailRowHeight', index);
                        },
                        onLoadSuccess: function () {
                            setTimeout(function () {
                                $('#topicPass').datagrid('fixDetailRowHeight', index);
                            }, 0);
                        }
                    });
                    $('#topicPass').datagrid('fixDetailRowHeight', index);
                }
            });
            //设置分页
            var p = $("#topicPass").datagrid("getPager");
            $(p).pagination({
                //每页显示的记录条数，默认为10   
                pageList: [15, 30, 50], //可以设置每页记录条数的列表   
                beforePageText: '第', //页数文本框前显示的汉字   
                afterPageText: '页    共 {pages} 页',
                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'

            });
            //            //未用审核通过的topic
            $("#topicHis").datagrid({
                url: '../MeetingPre/MeetingOperation.ashx?method=GetUseTopic&CategoryId=' + CategoryId,
                pagination: true,
                singleSelect: true,
                pageSize: 15,
                pageNumber: 1, //默认索引页 
                view: detailview,
                detailFormatter: function (index, row) {
                    return '<div style="padding:2px"><table id="ddv-' + index + '"></table></div>';
                },
                onExpandRow: function (index, row) {
                    $('#ddv-' + index).datagrid({
                        url: '../MeetingPre/MeetingOperation.ashx?method=GetTopicApprove&Id=' + row.Id,

                        singleSelect: true,
                        rownumbers: true,
                        loadMsg: '',
                        height: 'auto',

                        columns: [[
                           { field: 'EmployeeName', title: '征求对象', width: 130 },
                              { field: 'IsPass', title: '审批状态', formatter: formatPass, hidden: true },
                              { field: 'InputType', title: '', hidden: true },
                              { field: 'Path', title: '', hidden: true },
                              { field: 'TopicId', title: '', hidden: true },
                              { field: 'EmployeeId', title: '', hidden: true },
                            { field: 'Comment', title: '签署意见', width: 220, formatter: formatComment }
                        ]],
                        onResize: function () {
                            $('#topicHis').datagrid('fixDetailRowHeight', index);
                        },
                        onLoadSuccess: function () {
                            setTimeout(function () {
                                $('#topicHis').datagrid('fixDetailRowHeight', index);
                            }, 0);
                        }
                    });
                    $('#topicHis').datagrid('fixDetailRowHeight', index);
                }
            });
            var p2 = $("#topicHis").datagrid("getPager");
            $(p2).pagination({
                //每页显示的记录条数，默认为10   
                pageList: [15, 30, 50], //可以设置每页记录条数的列表   
                beforePageText: '第', //页数文本框前显示的汉字   
                afterPageText: '页    共 {pages} 页',
                displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'

            });

            $("#topicSelected").datagrid({});


            //签署意见 
            function formatComment(val, row) {
                if (row.InputType == 1)  //InputType = 1 代表文字内容
                {
                    return val;
                } else if (row.InputType == 2) {
                    var url = "../../upload/approve/topic/" + row.Path + "/" + row.TopicId + "/" + row.EmployeeId + ".png";
                    return "<a href='" + url + "' target='_blank' >点击查看</a>";
                } else {
                    return val;
                }
            }

            function formatPass(val, row) {
                if (row.IsPass == true)
                    return "通过";
                else
                    return "未通过";
            }
        });

        var selJson = "";
        function GetSelectTopic() {
            var rows = $("#topicSelected").datagrid("getRows");
            var row;
            for (i = 0; i < rows.length; i++) {
                //selJson += "," + JSON.stringify(rows[i]);
                row = rows[i];
                selJson += ',' + '{"TopicId":"' + row.Id + '","Title":"' + row.Title + '","EmployeeId":"' + row.EmployeeId + '","EmployeeName":"' + row.EmployeeName
                + '","EmployeeTitle":"' + row.EmployeeTitle + '","RoleId":"' + row.RoleId + '","Sort":10}';
            }
            //            var rows = $("#topicHis").datagrid("getSelections");
            //            for (i = 0; i < rows.length; i++) {
            //                row = rows[i];
            //                selJson += ',' + '{"TopicId":"' + row.Id + '","Title":"' + row.Title + '","EmployeeId":"' + row.EmployeeId + '","EmployeeName":"' + row.EmployeeName
            //                + '","EmployeeTitle":"' + row.EmployeeTitle + '","RoleId":"' + row.RoleId + '","Sort":10}';
            //            }
        }

        function SelectOk() {
            GetSelectTopic();
            if (selJson.length > 0) selJson = selJson.substring(1);
            selJson = "[" + selJson + "]";
            //提交 
            art.dialog.data('result', "true");
            art.dialog.data('selJson', selJson);
            art.dialog.close();
        }
        function DoSearch() {
            var name = $("#fName").val();
            $("#topicPass").datagrid("reload", { Title: name });
            $("#topicHis").datagrid("reload", { Title: name });
        }
    </script>
    <style type="text/css">
        input, textarea
        {
            border: 1px solid #AED0EA;
            padding: 2px;
            height: 20px;
        }
    </style>
</head>
<body style=" margin-left:5px; margin-top:1px;">
    <form id="form1" runat="server">
    <div>
        <span style="font-size:12px; font-weight:bold; color:Red;">已选择议题</span>
        <table id="topicSelected" nowrap="false" style="width: 620px; height: 150px;">
            <!--最新通过的议题-->
            <thead>
                <tr>
                    <th data-options="field:'Id',width:80,hidden:true">
                        Item ID
                    </th>
                    <th data-options="field:'Title',width:460">
                        标题
                    </th>
                    <th data-options="field:'EmployeeTitle',width:80,hidden:true">
                        职务
                    </th>
                    <th data-options="field:'EmployeeId',width:80,hidden:true">
                    </th>
                    <th data-options="field:'EmployeeName',width:50">
                        主讲人
                    </th>
                    <th data-options="field:'RoleId',width:250,hidden:true">
                    
                    </th>
                    <th data-options="field:'action1',width:65,formatter:DelSelect">
                    删除选用
                    </th>
                </tr>
            </thead>
        </table>
    </div>
    <table  >
        <tr>
            <td width="80px">
                议题名称:
            </td>
            <td width="80px">
                <input id="fName" style="width: 120px;" class="easyui-validatebox" />
            </td>
            <td width="340px">
                <a href="#" class="easyui-linkbutton" onclick="DoSearch();">查询</a>
            </td>
            <td style="text-align:right;">
                <a id="A1" class="easyui-linkbutton" onclick="SelectOk();">确定</a>
            </td>
        </tr>
    </table>
    <div>
        <div id="tt" class="easyui-tabs" style="width: 620px; height: 300px;">
            <div title="上会议题" style="padding: 5px;">
                <table id="topicPass" nowrap="false" style="width: 615px; height: 250px">
                    <!--最新通过的议题-->
                    <thead>
                        <tr>
                            <th data-options="field:'Id',width:80,hidden:true">
                                Item ID
                            </th>
                            <th data-options="field:'Title',width:455">
                                标题
                            </th>
                            <th data-options="field:'EmployeeTitle',width:80,hidden:true">
                                职务
                            </th>
                            <th data-options="field:'EmployeeId',width:80,hidden:true">
                            </th>
                            <th data-options="field:'EmployeeName',width:50">
                                主讲人
                            </th>
                            <th data-options="field:'RoleId',width:250,hidden:true">
                                主讲人
                            </th>
                            <%-- <th data-options="field:'chk',checkbox:true">
                            </th>--%>
                            <th data-options="field:'actionColumn',width:40,formatter:formatTopicSelect">
                                选用
                            </th>
                        </tr>
                    </thead>
                </table>
            </div>
            <div title="已用议题" style="overflow: auto; padding: 5px;">
                <table id="topicHis" nowrap="false" style="width: 615px; height: 250px">
                    <thead>
                        <tr>
                            <th data-options="field:'Id',width:80,hidden:true">
                                Item ID
                            </th>
                            <th data-options="field:'Title',width:455">
                                标题
                            </th>
                            <th data-options="field:'EmployeeTitle',width:80,hidden:true">
                                职务
                            </th>
                            <th data-options="field:'EmployeeId',hidden:true">
                            </th>
                            <th data-options="field:'EmployeeName',width:50">
                                主讲人
                            </th>
                            <th data-options="field:'RoleId',hidden:true">
                                主讲人
                            </th>
                            <%-- <th data-options="field:'chk',checkbox:true">
                            </th>--%>
                            <th data-options="field:'actionColumn',width:40,formatter:formatTopicSelect">
                                选用
                            </th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function SetSelect(id, title, empId, empName, empTitle, roleId) {

            var rows = $('#topicSelected').datagrid('getRows');
            for (i = rows.length - 1; i >= 0; i--) {
                if (rows[i].Id == id) return;
            }
            $('#topicSelected').datagrid('appendRow', { Id: id, Title: title, EmployeeId: empId, EmployeeName: empName, EmployeeTitle: empTitle, RoleId: roleId });

        }

        function formatTopicSelect(val, row) {
            return "<a href='#' class='easyui-linkbutton' onclick=\"SetSelect('" + row.Id + "','" + row.Title + "','" + row.EmployeeId + "','" + row.EmployeeName + "','" + row.EmployeeTitle + "','" + row.RoleId + "');\"  >选用</a> ";
        }


        //从已选择中移除
        function DelSelect(val, row) {
            return "<a href='#' class='easyui-linkbutton' onclick=\"RemoveSelect('" + row.Id + "');\"  >移除</a> ";
        }
        function RemoveSelect(Id) {
            var data = $('#topicSelected').datagrid('getData');
            var index = -1;
            for (i = 0; i < data.total; i++) {
                if (data.rows[i].Id == Id) {
                    index = i;
                    break;
                }
            }
            $('#topicSelected').datagrid('deleteRow', index);
        }
    </script>
    </form>
</body>
</html>
